package com.vivo.retail.service;


import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.vivo.retail.dao.VivoConsumerExchangeOrderDao;
import com.vivo.retail.entity.VivoConsumerExchangeOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class VivoConsumerExchangeOrderService extends CrudService<VivoConsumerExchangeOrderDao, VivoConsumerExchangeOrder> {

    @Autowired
    private VivoConsumerExchangeOrderDao vivoConsumerExchangeOrderDao;

    public VivoConsumerExchangeOrder get(String id) {
        return super.get(id);
    }

    public VivoConsumerExchangeOrder getLast(VivoConsumerExchangeOrder vivoConsumerExchangeOrder) {
        return vivoConsumerExchangeOrderDao.getLastChangeData(vivoConsumerExchangeOrder);
    }

    public List<VivoConsumerExchangeOrder> findList(VivoConsumerExchangeOrder vivoConsumerExchangeOrder) {
        return super.findList(vivoConsumerExchangeOrder);
    }

    public Page<VivoConsumerExchangeOrder> findPage(Page<VivoConsumerExchangeOrder> page, VivoConsumerExchangeOrder order){
        return super.findPage(page, order);
    }

    @Transactional(readOnly = false)
    public void insertByBatch(List<VivoConsumerExchangeOrder> oderList, String area) {
        if (area.equals("ah")) {
            vivoConsumerExchangeOrderDao.insertByBatchAh(oderList);
        } else {
            vivoConsumerExchangeOrderDao.insertByBatchJs(oderList);
        }
    }
}
